#include "comm/boot_info.h"
#include "cpu/cpu.h"
#include "tools/log.h"
#include "tools/klib.h"
#include "core/task.h"
#include "comm/cpu_instr.h"
/**
 * 内核入口
 */
void kernel_init (boot_info_t * boot_info) { 
    cpu_init();
    log_init();
    irq_init();
}

static task_t first_task;       // 第一个任务
static uint32_t init_task_stack[1024];	// 空闲任务堆栈
static task_t init_task;


void init_task_entry(void){
    int count =0;
    for(;;){
        log_printf("init_task:%d",count++);
        task_switch_from_to(&init_task,&first_task);
    }
}
void init_main(void) {
    task_init(&init_task, (uint32_t)init_task_entry, (uint32_t)&init_task_stack[1024]);
    task_init(&first_task, 0, 0);
    write_tr(first_task.tss_sel);
     int count = 0;
    for (;;) {
        log_printf("first task: %d", count++);
        task_switch_from_to(&first_task, &init_task);
    }
}
